﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ywxt.Common;

namespace DB_NH.DB_Model.gxjdWebSite
{
    using NHibernate;
    using NHibernate.Mapping.ByCode;
    using NHibernate.Mapping.ByCode.Conformist;

    /// <summary>
    /// 部门表
    /// </summary>
    [Serializable]
    public class Department
    {
        /// <summary>
        /// 部门ID
        /// </summary>
        public virtual string dept_id { get; set; }
        public Department()
        {
            dept_id = Common.NewID();
            this.sub_departments = new List<Department>();
        }

        /// <summary>
        /// 部门名称
        /// </summary>
        public virtual string dept_name { get; set; }

        /// <summary>
        /// 部门代码
        /// </summary>
        public virtual string dept_code { get; set; }

        /// <summary>
        ///  创建时间
        /// </summary>
        public virtual DateTime create_date { get; set; }

        /// <summary>
        /// 部门级别
        /// </summary>
        public virtual int dept_level { get; set; }

        /// <summary>
        /// 是否叶子节点
        /// </summary>
        public virtual int is_leaf { get; set; }

        /// <summary>
        /// 部门联系电话
        /// </summary>
        public virtual string dept_phone { get; set; }

        /// <summary>
        /// 部门传真
        /// </summary>
        public virtual string dept_fax { get; set; }

        /// <summary>
        ///  部门联系人
        /// </summary>
        public virtual string dept_linker { get; set; }

        /// <summary>
        ///  部门邮件
        /// </summary>
        public virtual string dept_email { get; set; }

        /// <summary>
        ///  路径
        /// </summary>
        public virtual string dept_path { get; set; }

        /// <summary>
        /// is_valid
        /// </summary>
        public virtual int is_valid { get; set; }

        /// <summary>
        /// 上一级分类
        /// </summary>
        public virtual Department pre_department { get; set; }

        /// <summary>
        /// 下一级分类
        /// </summary>
        public virtual IList<Department> sub_departments { get; set; }

      

        /// <summary>
        /// 添加当前专家分类的子分类
        /// </summary>
        /// <param name="_child"></param>
        public virtual void addChild(Department _child)
        {
            _child.pre_department = this;
            _child.dept_level = this.dept_level + 1;
            _child.dept_path = this.dept_path + "/" + _child.dept_id;
            this.sub_departments.Add(_child);
        }
    }
}
